package com.smartcommunity.service.common;

import com.smartcommunity.base.common.CacheMap;
import com.smartcommunity.bean.entity.Village;
import com.smartcommunity.dao.village.VillageDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName: CommonService
 * @Description: 公共接口用于刷新缓存
 * @author: minsheng
 * @Date: 2019/1/3 13:41
 * @Company:
 * @version V1.5.0
 */
@Service
@Slf4j
public class CommonService {

    @Autowired
    private VillageDao villageDao;

    /**
     * @Description: 刷新小区信息
     * @author: minsheng
     * @date: 2019/1/3 13:42
     */
    public void refreshVillage() {
        log.info("刷新缓存小区信息！");
        List<Village> villageList = villageDao.getAllVillageInfo();
        for (Village village :villageList){
            CacheMap.VILLAGE_INFO_MAP.put(village.getVillageCode(), village);
        }
        log.info("刷新小区信息结束！");
    }





	/*public void clearAll(){
        Iterator<String> it = CacheSupport.keySet.iterator();
        while (it.hasNext()){
            String key = it.next();
            redisUtil.delete(key);
            it.remove();
        }
    }*/
}
